package com.geo.geoProject.client.UI.fenetres;

import com.geo.geoProject.client.application.Programme.ConfigurationFenetre;
import com.google.gwt.user.client.ui.Widget;
import com.smartgwt.client.types.HeaderControls;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HeaderControl;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;

public class FenetreApplication extends Window {
	
	EvenementsTitreFenetre listener = null ;
	
	public FenetreApplication(Widget content, String title, Canvas c, ConfigurationFenetre config) {
		
        ClickHandler clickHandler = new ClickHandler() {  
            public void onClick(ClickEvent event) {  
            	if (listener!=null) {
            		listener.clickMinimiser() ;
            	}
            }  
        };  
		
		HeaderControl minimize = new HeaderControl(HeaderControl.MINIMIZE, clickHandler);  
		setHeaderControls(HeaderControls.HEADER_LABEL, minimize); 
		
        setAutoSize(true);  
        if (title!=null)
        	setTitle(title);  
        setCanDragReposition(true);   
        setCanDragResize(true);  
        addItem(content);

        setShowCloseButton(false) ;

        setShowShadow(true) ;
        setShadowDepth(8) ;

        setShowResizer(true) ;
        if (config!=null) {
            setShowStatusBar(config.ShowFooter) ;
        } else {
        	setShowStatusBar(false) ;
        }
        setShowResizeBar(true) ;

        
        setCanDragResize(true);  
        if (config!=null) {
        	setShowFooter(config.ShowFooter);  
        } else {
        	setShowFooter(false);  
        }
        
        
        if (c!=null)
        	c.addChild(this) ;
        
        setVisible(false) ;
	}

	public void setListener(EvenementsTitreFenetre listener) {
		this.listener = listener;
	}
	
}
